<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
    <script src="./lib/vue-router-3.0.1.js"></script>
    <style>
        [v-cloak] {
            display: none;
            font-size: 20px;
        }
    </style>
</head>

<body>
    <div id="app">
        <span c-cloak>{{msg}}</span>
        <ul>
            <li v-for="item in list" :key=item.id>{{item.name}}</li>
        </ul>
        <div @click.self="add2">
            <button @click.once="add" v-text="msg"> </button>
        </div>
        <!-- <input type="button" :value="msg" style="display: block"> -->
        <!-- <router-link to="/login?id=123">link</router-link> -->
        <router-link to="/login/123/feng">link</router-link>
        <router-view></router-view>
    </div>
    <script>
        var login = {
            // template: '<h2>我是一个h标题{{$route.query.id}}</h2>'
            template: '<h2>我是一个h标题{{$route.params.id}}{{$route.params.name}}</h2>'
        }
        //路由
        var router = new VueRouter({
            routes: [
                { path: '/login/:id/:name', component: login }
            ]
        })
        var vm = new Vue({
            el: '#app',
            router,
            data: {
                msg: '<h3>这是个三级标题</h3>',
                list: [
                    { id: '1233', name: '你好' },
                    { id: '1233', name: '你好' }
                ],
                abc: { id: '1233', name: '你好' }

            },
            methods: {
                add() {
                    // console.log(JSON.parse(this.abc))
                    console.log("in");

                    // alert(this.abc)
                },
                add2() {
                    // console.log(JSON.parse(this.abc))
                    // console.log(this.abc);
                    console.log("diergeadd3outer ");


                    // alert(this.abc)
                }
            },
            created(){
                console.log(this.$route)
            }
        })
    </script>
</body>

</html>